package com.kucai.yifaqapp.util;

import android.content.Context;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;

public class ContactUtils {

    private static final String TAG = "ContactUtils";

    public static String StreamToStr(Context context, String fileName)
            throws IOException {

        // 获取一个输入流
        InputStream inputStream = context.getAssets().open(fileName);
        // 定义一个字节数组输出流
        ByteArrayOutputStream arrayOutputStream = new ByteArrayOutputStream();
        // 定义一个字节数组
        byte[] buffer = new byte[1024];
        // 定义一个初始长度
        int len = 0;
        while ((len = inputStream.read(buffer)) != -1) {
            arrayOutputStream.write(buffer, 0, len);
        }
//        Log.i(TAG, arrayOutputStream.toString());
        return arrayOutputStream.toString();
    }
}

